package smashedapples.amazon
{
	import smashedapples.amazon.productapi.IRequest;
	import smashedapples.amazon.productapi.ProductApiConsts;
	import smashedapples.core.NonVisualComponent;
	
	[DefaultProperty("requests")]
	public class ProductApi extends NonVisualComponent
	{
		
		public var Locale:String = "";
		public var AWSAccessKeyId:String = "";
		public var Version:String = ProductApiConsts.VERSION_2009_05_08;
		public var AssociateTag:String;
		
		
		private var _requests:Array = [];
		
		[ArrayElementType("smashedapples.amazon.productapi.IRequest")]
		public function get requests():Array
		{
			return _requests;
		}
		
		public function set requests( value:Array ):void
		{
			_requests = value;
			this.addPropertyChanged( "requests" );
		}
		
		public function onCommitRequests():void
		{
			for each( var request:IRequest in this.requests )
			{
				this.addRequest( request );
			}
		}
		
		public function addRequest( request:IRequest ):void
		{
			request.api = this;
		}
		
		
		
	}
}